<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

    
function get_page_link($inpage, $text){
    global $page;
    $xtpl = new XTemplate('home.html',PAGE_PATH.DS.DS.$page.DS.DS.'tpl');
    $xtpl->assign("PAGE", $inpage);
    $xtpl->assign("PAGETEXT", $text);
    $xtpl->parse( 'user_list_page_link' );
    return $xtpl->text('user_list_page_link');
    
}


function get_page_nav_html($inpage, $count){
    $re = "Page ".$inpage." of ".$count." [".get_page_link(1, 1);
    if ($inpage>2){
        $re = $re." ".get_page_link($inpage-1, $inpage-1);
    }
    if ($inpage>1){
        $re = $re." ".$inpage;
    }

    if ($inpage<$count){
        $re = $re." ".get_page_link($inpage+1, $inpage+1);
    }

    if ($inpage+1 < $count){
        $re = $re." ".get_page_link($count, "LAST");
    }

    return $re." ]";
}


    function get_user_info_html($alt, $userinfo){
            global $page, $user, $template2;
            $xtpl = new XTemplate('users_info.html',PAGE_PATH.DS.DS.$page.DS.DS.'tpl');
            $html_class = "table_row_alt".$alt;
            $edit_img = LAYOUT_URL."/images/edit.png";
            $id=$userinfo["id"];
            $username=$userinfo["username"];
            $displayname=$userinfo["displayname"];
            $join_date=$userinfo["join_date"];
            $group = $user->get_group_name($userinfo["usergroups_id"]);
            $xtpl->assign('html_class', $html_class);
            $xtpl->assign('id', $id);
            $xtpl->assign('username', $username);
            $xtpl->assign('displayname', $displayname);
            $xtpl->assign('group', $group);
            $xtpl->assign('join_date', $join_date);
            $xtpl->assign('view', '<a href="'.ABS_URL.'?page=admin&act=edituser&userid='.$id.'"><img style="margin: 4px; border:0" src="'.$edit_img.'"></a>');
            $xtpl->parse( 'user' );
            $user_content= $xtpl->text('user');
            return $user_content;
    }


    function create_group_dropbox($selected=0){
        global $db;
        $res = '<select name="group" id="groupbox" return false;">';
        $sql = "SELECT * from usergroups ORDER BY id ASC";
        $rows= $db->query($sql, $fetchArray=true);
        for ($i=0; $i<count($rows); $i++){
            if($i == $selected){
                $res = $res.'<option selected="selected" value="'.$rows[$i][0].'">'.$rows[$i][1].'</option>';
            }else{
                $res = $res.'<option value="'.$rows[$i][0].'">'.$rows[$i][1].'</option>';
            }
        }
        return $res.'</select>';
    }

?>
